<?php

/**
 * This is the model class for table "month_report".
 *
 * The followings are the available columns in table 'month_report':
 * @property integer $month_report_id
 * @property string $owner_id
 * @property string $month
 * @property integer $joinmb
 * @property double $firstorderamount
 * @property integer $firstordernum
 * @property double $total_earn
 * @property integer $payment_status
 * @property string $payment_id
 * @property string $program
 * @property string $adddate
 */
class MonthReport extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return MonthReport the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'month_report';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('owner_id, payment_id, program', 'required'),
			array('joinmb, firstordernum, payment_status', 'numerical', 'integerOnly'=>true),
			array('firstorderamount, total_earn', 'numerical'),
			array('owner_id', 'length', 'max'=>30),
			array('payment_id, program', 'length', 'max'=>50),
			array('month, adddate', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('month_report_id, owner_id, month, joinmb, firstorderamount, firstordernum, total_earn, payment_status, payment_id, program, adddate', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'month_report_id' => 'Month Report',
			'owner_id' => 'Owner',
			'month' => 'Month',
			'joinmb' => 'Joinmb',
			'firstorderamount' => 'Firstorderamount',
			'firstordernum' => 'Firstordernum',
			'total_earn' => 'Total Earn',
			'payment_status' => 'Payment Status',
			'payment_id' => 'Payment',
			'program' => 'Program',
			'adddate' => 'Adddate',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('month_report_id',$this->month_report_id);
		$criteria->compare('owner_id',$this->owner_id,true);
		$criteria->compare('month',$this->month,true);
		$criteria->compare('joinmb',$this->joinmb);
		$criteria->compare('firstorderamount',$this->firstorderamount);
		$criteria->compare('firstordernum',$this->firstordernum);
		$criteria->compare('total_earn',$this->total_earn);
		$criteria->compare('payment_status',$this->payment_status);
		$criteria->compare('payment_id',$this->payment_id,true);
		$criteria->compare('program',$this->program,true);
		$criteria->compare('adddate',$this->adddate,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}